{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "name": "RebiberDemo.ipynb",
      "provenance": [],
      "collapsed_sections": [],
      "toc_visible": true
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    }
  },
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "z8VyxufF27KF"
      },
      "source": [
        "# A simple web demo of [Rebiber](https://github.com/yuchenlin/rebiber).\r\n",
        "\r\n",
        "We often cite papers using their arXiv versions without noting that they are already PUBLISHED in some conferences. These unofficial bib entries might violate rules about submissions or camera-ready versions for some conferences. We introduce Rebiber, a simple tool in Python to fix them automatically. It is based on the official conference information from the DBLP or the ACL anthology (for NLP confernces)! You can check the list of [supported conferences](https://github.com/yuchenlin/rebiber#supported-conferences)."
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "t30iKpqfyMWY"
      },
      "source": [
        "# Step 1/3: Install Rebiber."
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "7RA92IK-riIA"
      },
      "source": [
        "!pip install rebiber -U # Please ignore the warning about `restart the runtime`.\r\n",
        "!echo \"\" > input.bib  # Create an empty bib file where you can paste your bib."
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "j3Q6Yx5JxdCv"
      },
      "source": [
        "# Step 2/3: Put your bib file in this environment.\n",
        "\n",
        "You can either upload your bib file with the name as `xxx.bib`, or open the `input.bib` file and paste the content there. [This](https://raw.githubusercontent.com/yuchenlin/rebiber/main/rebiber/example_input.bib) is an example bib file."
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "hf76KVB807xf"
      },
      "source": [
        "!ls -lht *.bib  # Make sure you can see your bib file here."
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "86IqfWqeuN4R"
      },
      "source": [
        "import os, rebiber\r\n",
        "# Note that you need to use the path to your own bib file.\r\n",
        "all_bib_entries = rebiber.load_bib_file(\"input.bib\")\r\n",
        "print(\"# Input Bib Entries:\", len(all_bib_entries))"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "5YtwOkiCx59Q"
      },
      "source": [
        "# Step 3/3: Run this and you will get the output file."
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "f-iKH2EH1HQG"
      },
      "source": [
        "This will output the normalized bib files to `output.bib` (or a custom path)."
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "ErneihCjupuA"
      },
      "source": [
        "filepath = os.path.abspath(rebiber.__file__).replace(\"__init__.py\",\"\")\r\n",
        "bib_list_path = os.path.join(filepath, \"bib_list.txt\")\r\n",
        "bib_db = rebiber.construct_bib_db(bib_list_path, start_dir=filepath)\r\n",
        "rebiber.normalize_bib(bib_db, all_bib_entries, \"output.bib\")   "
      ],
      "execution_count": null,
      "outputs": []
    }
  ]
}